var str = 'dsfshkgfasssreasfd22222222';
var arr = str.split('');
// arr = arr.sort();
// str = arr.join('');

// 先进行排序处理，然后重新组装成字符串
var reg = /(\w)\1+/g;
var num = 0;
var value = null;
str.replace(reg, function($0, $1){
    if (num < $0.length) {
        num = $0.length;
        value = $1;
    };
});
console.log(value+'出现次数'+num);